package com.sckj.springboot.controller;

import com.sckj.springboot.entity.User;
import com.sckj.springboot.service.UserService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class TestController {

    @Resource
    private UserService userService;

    @RequestMapping("/adduser")
    public String addUser(@RequestBody User user) throws Exception{
        if (null != user){
            userService.insertUser(user);
            return "success";
        }else {
            return "false";
        }
    }

    @RequestMapping("/adduser2")
    public String addUser2(@RequestBody User user) throws Exception{
        if (user != null) {
            userService.insertUser2(user);
            return "success";
        }else {
            return "false";
        }
    }

    @RequestMapping("/adduser3")
    public String addUser3(@RequestBody User user) throws Exception{
        if (user != null) {
            userService.insertUser3(user);
            return "success";
        } else {
            return "false";
        }
    }

    @RequestMapping("/adduser4")
    public String addUser4(@RequestBody User user) throws Exception{
        if (user != null) {
            userService.insertUser4(user);
            return "success";
        } else {
            return "false";
        }
    }
}
